package com.step.ems.component

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.BoxScope
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import com.step.ems.common.UiState

@Composable
inline fun LoadingBox(
    modifier: Modifier = Modifier,
    state: UiState,
    contentAlignment: Alignment = Alignment.TopStart,
    propagateMinConstraints: Boolean = false,
    content: @Composable BoxScope.() -> Unit
) {
    Box(modifier, contentAlignment, propagateMinConstraints) {
        content()
        if (state is UiState.Loading) LoadingOverlay()
    }
}